In [1]:
using ValidatedNumerics
In [2]:
logistic(r, x) = -r*((x-0.5)^2 - 0.25) #r*x*(1-x)
Out[2]:
In [3]:
X = @interval(-0.0001, 1.0001)
Out[3]:
In [4]:
r = @interval(3.1)
newton(x -> logistic(r,x)-x, X)
Out[4]:
In [5]:
r = @interval(3.1)
newton(x -> logistic(r, logistic(r,x))-x, @interval(-1, 2))
Out[5]:
In [3]:
function iterate_logistic(n)
ex = :(x)
for i in 1:n
ex = :(logistic(r,$ex))
end
ex = :($(ex) - x)
ex
end
for n in [1, 2, 4, 5, 8:16, 32]
name = symbol("logistic_iterated_$n")
ex = iterate_logistic(n)
@eval $name(r,x) = $ex
end
In [5]:
iterate_logistic(4)
Out[5]:
In [14]:
logistic_iterated_16(3.1, 0)
Out[14]:
In [23]:
r = @interval(3.1)
newton(x -> logistic_iterated_2(r, x), X)
Out[23]:
In [22]:
r = @interval(3.5)
newton(x -> logistic_iterated_4(r, x), X)
Out[22]:
In [21]:
r = @interval(3.55)
newton(x -> logistic_iterated_8(r, x), X)
Out[21]:
In [20]:
r = @interval(3.55)
krawczyk(x -> logistic_iterated_8(r, x), X)
Out[20]:
In [19]:
r = @interval(4)
newton(x -> logistic_iterated_8(r, x), X)
Out[19]:
In [24]:
r = @interval(4)
newton(x -> logistic_iterated_16(r, x), X)
Out[24]:
In [26]:
roots = ans;
filter(x -> x[2]==:unique, roots)
Out[26]:
In [34]:
logistic_iterated_16(3.1, 0)
Out[34]:
In [29]:
newton(x->logistic_iterated_5(r, x), X)
Out[29]:
In [30]:
roots[roots[2]==:unique]
In [32]:
r = @interval(4)
newton(x -> logistic_iterated_10(r, x), X)
Out[32]:
In [33]:
length(filter(x->x[2]==:unique, ans))
Out[33]:
In [40]:
r = @interval(4)
newton(x -> logistic_iterated_11(r, x), X, tolerance=0, maxlevel=40)
Out[40]:
In [35]:
length(filter(x->x[2]==:unique, ans))
Out[35]:
In [36]:
newton(x->logistic_iterated_11(r, x), @interval("[0.9999994111193403, 0.9999994112365287]"))
Out[36]:
In [38]:
newton(x->logistic_iterated_11(r, x), @biginterval("[0.9999994111193403, 0.9999994112365287]"))
Out[38]:
In [39]:
diam(ans[1][1])
Out[39]:
When $r=4$, it is possible to calculate the periodic points exactly; see e.g. Sanders+Benet, Scipy 2014 proceedings. First we calculate the periodic points of the tent map using BigFloat
s:
In [25]:
function tent_map_periodic_points(n)
evens = big(1.0)/(big(2)^n-1) * collect(0:2:2^n-1)
odds = big(1.0)/(big(2)^n+1) * collect(2:2:2^n)
points = zeros(BigFloat, 2^n)
points[1:2:2^n] = evens
points[2:2:2^n] = odds
points
end
Out[25]:
In [26]:
tent_map_periodic_points(4)
Out[26]:
These points $y_n$ are mapped onto periodic points of the logistic map by $x := h(y) := \sin^2(\frac{\pi}{2} y)$
In [27]:
h(y) = sin(π*y/2)^2
Out[27]:
In [28]:
logistic_exact_period_4_points = map(h, tent_map_periodic_points(4))
Out[28]:
In [29]:
logistic_r4_period_4_points = find_roots(x -> logistic_iterated_4(4., x), -1e-10, 1+1e-10)
Out[29]:
These intervals do contain the exact roots:
In [31]:
all([logistic_exact_period_4_points[i] in logistic_r4_period_4_points[i].interval for i in 1:16])
Out[31]:
Note that this calculation does not work using standard floating point for the calculation of the exact points -- rounding errors result in floating point numbers that are outside these guaranteed bounds.